<?php

	/*
	database name:
	argumen6_mainDatabase
	
	table name:
	argumentMaps
	
	user name:
	argumen6_lkjasld
	xvkL#KS%TE!4
	 
	columns:
	title, map 
	 */

	echo('hello php is working <br/><br/>');

	$username="argumen6_lkjasld";
	$password="xvkL#KS%TE!4";
	$database="argumen6_mainDatabase";
	
	$title = "title";
	$map = "map";
	
	//connect to database
	//FIX ** this will have to be changed when uploaded
	$con = mysql_connect("127.0.0.1:3306",$username,$password);
	mysql_select_db($database, $con);

	
	//see if entry already exists	
	$result = mysql_query("SELECT title FROM argumentMaps WHERE title='" . $title . "'");
	
	echo("<br/>size of result : " . mysql_num_rows($result) );
	
	//if query comes back empty, create entry
	//must use single quote around sent data because JSON string uses double quotes around text
	if(mysql_num_rows($result) < 1){
		//create entry
		$query = "INSERT INTO argumentMaps (title, map)
			VALUES ('" . $title . "','" . $map . "')";
	}else{ //if already exists, update it
		$query = "UPDATE argumentMaps
			SET map='" . $map . "'
			WHERE title='" . $title . "'";
	}
	
	echo("<br/>" . $query);
	
	mysql_query($query);

	echo("<br/>" . mysql_error() );

	//***be sure to close after making the query
	mysql_close();
    //phpinfo();
    
?>